{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "26d52ad7",
   "metadata": {},
   "source": [
    "# Dimensions in Array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "47df926f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e1997937",
   "metadata": {},
   "source": [
    "## One dimensional Array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f8161ad5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3, 4])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([1,2,3,4])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d0466997",
   "metadata": {},
   "source": [
    "- Represented in single axis"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cd554137",
   "metadata": {},
   "source": [
    "## Two Dimensional Array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e242a951",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2],\n",
       "       [3, 4]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([[1,2],[3,4]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "07d21eea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3, 4]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array([[1,2,3,4]])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40b4651d",
   "metadata": {},
   "source": [
    "- Represented in rows and columns as matrix\n",
    "   - means 2 axis are required\n",
    "   \n",
    "- Representation\n",
    "    -   0  1\n",
    "    - 0 [1,2]\n",
    "    - 1 [3.4]\n",
    "- Axis becomes 0,1 and 0,1\n",
    "     - at (0,0) 1 is present\n",
    "     - at (0,1) 2 is present\n",
    "     - at (1,0) 3 is present\n",
    "     - at (1,1) 4 is present"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4c163bfb",
   "metadata": {},
   "source": [
    "## Checking dimension of array"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52ecbeae",
   "metadata": {},
   "source": [
    "- ndim attribute is used"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5fafc363",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a=np.array([1,2,3,4])\n",
    "a.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "22251914",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b=np.array([[1,2,3,4]])\n",
    "b.ndim"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}